<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use EloquentFilter\Filterable;

/**
 * App\Models\SinglePage
 *
 * @property int $id
 * @property int $user_id
 * @property string $title
 * @property string|null $description
 * @property int $status
 * @property int $allow_comment
 * @property int $views_count
 * @property int $comments_count
 * @property \Illuminate\Support\Carbon|null $published_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property string|null $deleted_at
 * @property-read \App\Models\Content $content
 * @property-read \App\Models\User $user
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage filter($input = array(), $filter = null)
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\SinglePage onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage paginateFilter($perPage = null, $columns = array(), $pageName = 'page', $page = null)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage simplePaginateFilter($perPage = null, $columns = array(), $pageName = 'page', $page = null)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereAllowComment($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereBeginsWith($column, $value, $boolean = 'and')
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereCommentsCount($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereDescription($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereEndsWith($column, $value, $boolean = 'and')
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereLike($column, $value, $boolean = 'and')
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage wherePublishedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereTitle($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereUserId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SinglePage whereViewsCount($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Models\SinglePage withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\SinglePage withoutTrashed()
 * @mixin \Eloquent
 */
class SinglePage extends Model
{
    use SoftDeletes, Filterable;

    protected $fillable = [
        'user_id', 'title',
        'published_at',
        'views_count', 'comments_count',
        'status', 'allow_comment',
        'keywords', 'description',
    ];

    protected $casts = [
        'id' => 'int',
        'user_id' => 'int',
        'status' => 'int',
        'allow_comment' => 'int',
        'views_count' => 'int',
        'comments_count' => 'int',
    ];


    protected $dates = [
        'published_at',
    ];

    protected $with = ['user'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }


    public function content()
    {
        return $this->morphOne(Content::class, 'contentable');
    }
}